package com.dj.ms.aop;


import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.dj.ms.annotation.TinyIdByType;
import com.xiaoju.uemc.tinyid.client.utils.TinyId;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class CustomIdGenerator implements IdentifierGenerator {

    @Override
    public Long nextId(Object entity) {
        TinyIdByType annotation = entity.getClass().getDeclaredAnnotation(TinyIdByType.class);
        return TinyId.nextId(annotation.byType());
    }
}
